package org.xhy.hrm.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.xhy.hrm.dto.SmsCodeDto;
import org.xhy.hrm.properties.ImgProperties;
import org.xhy.hrm.service.IVerifyCodeService;
import org.xhy.hrm.util.AjaxResult;
import org.xhy.hrm.util.StrUtils;

@RestController
@RequestMapping("verifycode")
public class VerifyCodeController {

    @Autowired
    private IVerifyCodeService verifyCodeService;

    /**
     * 图片验证码
     * @param key
     * @return
     */
    @GetMapping("/imageCode/{key}")
    public AjaxResult imageCode(@PathVariable("key")String key){
        String base64 = verifyCodeService.imageCode(key);
        return AjaxResult.me().setResultObj(base64);
    }

    /**
     * 短信验证码
     * @param
     * @return
     */
    @PostMapping("/sendSmsCode")
    public AjaxResult sendSmsCode(@RequestBody SmsCodeDto dto){
        verifyCodeService.sendSmsCode(dto);
        return AjaxResult.me();
    }

}
